<template>
  <div>
    <!-- 首页 -->
    <div class="title">
      <span class="text">编辑精选</span>
      <span class="logo"
        ><img
          src="http://s0.mtime.cn/public/nodewww/20211125103924/images/todayRecmd.png"
          alt="今日推荐"
      /></span>
    </div>
    <!-- 编辑精选 -->
    <div class="box1">
      <ul>
        <li v-for="item in jx" :key="item.id" @click="gotoxq(item.id)">
          <img :src="basurl + item.url" alt="图片" />
          <h3>{{ item.name }}</h3>
          <p>{{ item.briefly }}</p>
        </li>
      </ul>
      <div class="order" @click="toorder">查看更多</div>
    </div>
    <div class="soid"></div>
    <!-- 今日推荐 -->
    <div class="title">
      <span class="text">今日推荐</span>
      <span class="ordertext" @click="toorder">更多></span>
    </div>
    <div class="box2">
      <ul>
        <li v-for="item in jr" :key="item.id"  @click="gotoxq(item.id)">
          <img :src="basurl + item.url" alt="图片" />
          <h3>{{ item.name }}</h3>
          <div>前往评论</div>
        </li>
      </ul>
    </div>
    <!-- 新片预告 -->
    <div class="box3">
      <div class="title">
        <span class="text">新片预告</span>
        <span class="ordertext" @click="toorder">更多></span>
      </div>
      <div class="newvie">
        <div v-for="item in xp" :key="item.id"  @click="gotoxq(item.id)">
          <img
            :src="basurl+item.url"
            alt="图片"
          />
          <p>{{item.briefly}}</p>
          <a>{{item.year}} {{item.area}} 上映</a>
        </div>
      </div>
    </div>
    <!-- 热门影评 -->
    <div class="title">
      <span class="text">热门影评</span>
      <span class="ordertext" @click="toorder">更多></span>
    </div>
    <div class="box4">
      <ul>
        <li v-for="item in pl" :key="item.id"  @click="gotoxq(item.id)">
          <img
          class="box4img"
            :src="basurl+item.url"
            alt="图片"
          />
          <div>
            <p>
             {{item.content}}
            </p>
            <span class="name">《{{item.name}}》</span> <a class="pin">{{item.score}}</a>
          </div>
        </li>
      </ul>
    </div>
    <!-- 热门排行 -->
    <div class="box5">
      <div class="title">
        <span class="text">热门排行</span>
        <span class="ordertext" @click="toorder">更多></span>
      </div>
      <div class="ranking">
        <ul>
          <li v-for="item in jx" :key="item.id"  @click="gotoxq(item.id)">
            <img
              :src="basurl+item.url"
              alt="图片"
            />
            <div>
              <p class="one">{{item.name}}</p>
              <p class="tow">
                {{item.briefly}}
              </p>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <!-- order -->
    <div class="title">
      <span class="text">发现更多</span>
      <span class="ordertext" @click="toorder">更多></span>
    </div>
    <div class="box1">
      <ul>
        <li v-for="item in jx" :key="item.id" @click="gotoxq(item.id)">
          <img :src="basurl+item.url" alt="图片" />
          <h3>{{ item.name }}</h3>
          <p>{{ item.tit }}</p>
        </li>
      </ul>
      <div class="order" @click="toorder">查看更多</div>
    </div>
  </div>
</template>

<script>
import { getjx, getjr, getxp,getpl } from "@/api/index";
export default {
  data() {
    return {
      list: [
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
          tit: "dgfer",
        },
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
          tit: "dgfer",
        },
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
          tit: "dgfer",
        },
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
          tit: "dgfer",
        },
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
          tit: "dgfer",
        },
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
          tit: "dgfer",
        },
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
          tit: "dgfer",
        },
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
          tit: "dgfer",
        },
      ],
      today: [
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
        },
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
        },
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
        },
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
        },
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
        },
        {
          img: "https://pic4.zhimg.com/v2-13ee1f2e14d10b8686f91bea4c03bf77_r.jpg",
          name: "sdff",
        },
      ],
      basurl: "http://127.0.0.1:7001",
      jx: [],
      jr: [],
      xp: [],
      pl:[]
    };
  },
  created() {
    this.getdata();
  },
  methods: {
    //跳转
    toorder() {
      this.$router.push("/Classs");
    },
    gotoxq(id){
      sessionStorage.setItem('id',id)
      this.$router.push('/details');
    },
    //精选
    getdata() {
      getjx().then((res) => {
        if (res.code == 0) {
          this.jx = res.data;
        } else {
          console("请求失败");
        }
      });
      getjr().then((res) => {
        if (res.code == 0) {
          this.jr = res.data;
        } else {
          console("请求失败");
        }
      });
      getxp().then((res) => {
        if (res.code == 0) {
          this.xp = res.data
        } else {
          console("请求失败");
        }
      });
      getpl().then((res) => {
        if (res.code == 0) {
          this.pl = res.data
        } else {
          console("请求失败");
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.title {
  width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.text {
  font-size: 24px;
  color: #6e6e6e;
}
.ordertext {
  color: #6e6e6e;
  cursor: pointer;
  &:hover {
    color: #1e7dd7;
  }
}
.order {
  width: 160px;
  border: 1px solid #666;
  text-align: center;
  color: #666;
  border-radius: 20px;
  margin: 0 auto;
  line-height: 35px;
  cursor: pointer;
  &:hover {
    background: #1e7dd7;
    color: #fff;
    border: 1px solid #1e7dd7;
  }
}
.soid {
  width: 1200px;
  height: 1px;
  background: #d9d9d9;
  margin: 30px auto;
}
.Rota {
  width: 450px;
}
.box1 {
  width: 1200px;
  margin: 10px auto;
  ul {
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    li {
      width: 285px;
      margin-bottom: 20px;
      cursor: pointer;
      img {
        width: 285px;
        height: 160px;
        object-fit: cover;
      }
      h3 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      p {
        color: #6e6e6e;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
}
.box2 {
  width: 1200px;
  margin: 20px auto;
  ul {
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    li {
      width: 170px;
      cursor: pointer;
      img {
        width: 170px;
        height: 256px;
        object-fit: cover;
      }
      h3 {
        width: 170px;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      div {
        width: 120px;
        height: 28px;
        text-align: center;
        border-radius: 50px;
        background: #1e7dd7;
        color: #fff;
        margin: 0 auto;
        line-height: 28px;
        cursor: pointer;
      }
    }
  }
}
.box3 {
  margin-top: 80px;
  background: #1e2736;
  padding: 30px 0;
  height: 650px;
  margin-bottom: 100px;
  span {
    color: #fff;
  }
  &:not(:nth-child(1)) {
    position: relative;
  }
  .newvie {
    width: 1200px;
    margin: 0 auto;
    div {
      float: left;
      &:not(:nth-child(1)) {
        img {
          width: 310px;
          height: 186px;
          position: absolute;
        }
        p {
          font-size: 16px;
          color: #fff;
          position: absolute;
        }
        a {
          font-size: 14px;
          color: #fff;
          position: absolute;
        }
      }
      &:nth-child(1) {
        img {
          width: 864px;
          height: 520px;
          margin-top: 20px;
          margin-right: 26px;
        }
        p {
          color: #fff;
          font-size: 24px;
          margin: 5px 0;
        }
        a {
          color: #fff;
        }
      }
      &:nth-child(2) {
        img {
          top: 11%;
        }
        p {
          top: 29%;
        }
        a {
          top: 32%;
        }
      }
      &:nth-child(3) {
        img {
          top: 38%;
        }
        p {
          top: 56%;
        }
        a {
          top: 59%;
        }
      }
      &:nth-child(4) {
        img {
          top: 65%;
        }
        p {
          top: 83%;
        }
        a {
          top: 86%;
        }
      }
    }
  }
}
.box4 {
  width: 1200px;
  margin: 20px auto;
  ul {
    display: flex;
    list-style: none;
    flex-wrap: wrap;
    justify-content: space-between;
    li {
      width: 330px;
      display: flex;
      margin-top: 10px;
      cursor: pointer;
      .box4img {
        width: 100px;
        height: 140px;
        object-fit: cover;
      }
      div {
        width: 300px;
        p {
          width:300px;
          color: #606266;
          margin-left: 5px;
          display: -webkit-box;
          overflow: hidden;
          -webkit-line-clamp: 4;
          -webkit-box-orient: vertical;
          line-height: 25px;
          text-indent: 2em;
          &:hover {
            cursor: pointer;
            color: #1e7dd7;
          }
        }
        .name {
          color: #888;
          font-size: 12;
          margin-left: 5px;
          margin-top: 10px;
          display: inline-block;
        }
        .pin {
          display: inline-block;
          background: #74ab34;
          width: 32px;
          height: 20px;
          text-align: center;
          line-height: 20px;
          color: #fff;
          font-size: 13px;
          margin-top: 10px;
        }
      }
    }
  }
}
.box5 {
  background: #eee;
  margin: 100px 0;
  padding: 20px 0;
  .ranking {
    width: 1200px;
    margin: 0 auto;
    ul {
      list-style: none;
      display: flex;
      flex-wrap: wrap;
      li {
        width: 600px;
        margin-top: 20px;
        display: flex;
        cursor: pointer;
        img {
          width: 100px;
          height: 100px;
          object-fit: cover;
        }
        div {
          margin-left: 20px;
          padding-right: 20px;
          p {
            width: 457px;
            &:nth-child(1) {
              font-weight: 700;
              margin-top: 10px;
            }
            &:nth-child(2) {
              color: #606266;
              margin-top: 10px;
            }
          }
        }
      }
    }
  }
}
</style>